package com.joven.shelltest.config;

import com.joven.shelltest.interceptor.AutoIdempotentInterceptor;
import com.joven.shelltest.interceptor.IpWhiteListInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.annotation.Resource;

/**
 * @Author wzj
 * @Date 2023-07-27 08:55
 **/
@Configuration
public class WebConfiguration extends WebMvcConfigurerAdapter {
    @Resource
    private AutoIdempotentInterceptor autoIdempotentInterceptor;
    @Resource
    private IpWhiteListInterceptor ipWhiteListInterceptor;

    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(autoIdempotentInterceptor);
        registry.addInterceptor(ipWhiteListInterceptor).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
